package controllers;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

import modelo.Insumo;
import modelo.Menu;
import modelo.Propietario;
import modelo.Salon;
import modelo.Servicioadicionalxsalon;
import modelo.Tiposuscripcion;
import modelo.Usuario;
import services.InsumoService;
import services.MenuService;
import services.PropietarioService;
import services.SalonService;
import services.ServicioAdicionalXSalonService;
import services.TipoSuscripcionService;


@ManagedBean
@ViewScoped
public class ConsultarMenuBean implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -7267319135561739444L;

	@ManagedProperty("#{menuService}")
	private MenuService serviceMenu=new MenuService();
	private Menu menu=new Menu();

	@ManagedProperty("#{salonService}")
	private SalonService serviceSalon=new SalonService();
	private Salon salon=new Salon();
	
	@ManagedProperty("#{insumoService}")
	private InsumoService serviceInsumo=new InsumoService();;
	List<Insumo> listaInsumos = new ArrayList<Insumo>();
	private Insumo insumoSelected=new Insumo();		
	
	private List<Menu> listaMenuSalon;
	private Menu menuSelected;
	
	
	public ConsultarMenuBean() {
		super();
		listaMenuSalon=new ArrayList<Menu>();
		menuSelected=new Menu();
	}

	@PostConstruct
	private void init() {
        FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
        HttpSession sessionActual = (HttpSession) context.getExternalContext().getSession(false);
        Integer salonSel = null;
        
        if (sessionActual!= null)
        {  salonSel = Integer.parseInt(sessionActual.getAttribute("salon").toString());             
        
        listaMenuSalon=serviceMenu.getListaMenuSalon(salonSel);
        salon=serviceSalon.obtenerSalon(salonSel);
        }
        else
        {
        	
        	
        }
        

	}


	public void llenarTablaInsumos(){
		listaInsumos = serviceInsumo.obtenerInsumosMenu(menuSelected.getIdMenu());
	}

	public MenuService getServiceMenu() {
		return serviceMenu;
	}

	public void setServiceMenu(MenuService serviceMenu) {
		this.serviceMenu = serviceMenu;
	}

	public Menu getMenu() {
		return menu;
	}

	public void setMenu(Menu menu) {
		this.menu = menu;
	}

	public InsumoService getServiceInsumo() {
		return serviceInsumo;
	}

	public void setServiceInsumo(InsumoService serviceInsumo) {
		this.serviceInsumo = serviceInsumo;
	}

	public List<Insumo> getListaInsumos() {
		return listaInsumos;
	}

	public void setListaInsumos(List<Insumo> listaInsumos) {
		this.listaInsumos = listaInsumos;
	}

	public Insumo getInsumoSelected() {
		return insumoSelected;
	}

	public void setInsumoSelected(Insumo insumoSelected) {
		this.insumoSelected = insumoSelected;
	}

	public List<Menu> getListaMenuSalon() {
		return listaMenuSalon;
	}

	public void setListaMenuSalon(List<Menu> listaMenuSalon) {
		this.listaMenuSalon = listaMenuSalon;
	}

	public Menu getMenuSelected() {
		return menuSelected;
	}

	public void setMenuSelected(Menu menuSelected) {
		this.menuSelected = menuSelected;
	}

	public String agregarmenu()
	{
		
		return "AgregarMenu";
	}

	public Salon getSalon() {
		return salon;
	}

	public void setSalon(Salon salon) {
		this.salon = salon;
	}

	public SalonService getServiceSalon() {
		return serviceSalon;
	}

	public void setServiceSalon(SalonService serviceSalon) {
		this.serviceSalon = serviceSalon;
	}

	}
